package com.dingwen.treasure.file.service;

import com.dingwen.treasure.tkmybatis.entity.TreasureFile;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;

/**
 * 　FileService
 * 　@author dingwen
 * 　@date 2022/7/4
 */
public interface FileService {
    /**
     * 文件上传
     *
     * @param multipartFile 文件
     * @param treasureFile  文件信息
     * @return {@link List}<{@link TreasureFile}>
     */
    default TreasureFile upload(MultipartFile multipartFile, TreasureFile treasureFile) {
        return null;
    }

    /**
     * 上传
     *
     * @param inputStream 输入流
     * @param treasureFile    文件信息
     * @return {@link TreasureFile}
     */
    default TreasureFile upload(InputStream inputStream, TreasureFile treasureFile) {
        return null;
    }

    /**
     * 文件下载
     *
     * @param fileId   文件id
     * @param request  要求
     * @param response 回答
     */
    void download(Long fileId, HttpServletRequest request, HttpServletResponse response);


    /**
     * 预览
     *
     * @param fileId   文件id
     * @param response 响应
     */
    void preview(Long fileId, HttpServletResponse response);

    /**
     * 删除文件
     *
     * @param fileId 文件id
     */
    void remove(Long fileId);

}
